package com.practise;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Scanner;

//1.键盘录入小明生日(格式:1995-10-25)
//2.键盘录入小王生日(格式:2017年09月18日)
//3.计算小王与小明生日相差多少天?
public class PractiseDemo {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入小明的生日(格式:1995-10-25)");
        String s1 = sc.nextLine();
        System.out.println("请输入小王生日(格式:2017年09月18日)");
        String s2 = sc.nextLine();
        SimpleDateFormat sim1=new SimpleDateFormat("yyyy-MM-dd");
        long time1 = sim1.parse(s1).getTime();
        SimpleDateFormat sim2=new SimpleDateFormat("yyyy年MM月dd日");
        long time2 = sim2.parse(s2).getTime();
        //System.out.println("time1 = " + time1);
        //System.out.println("time2 = " + time2);
        long days = (time2 - time1) / (1000 * 60 * 60 * 24);
        System.out.println("小王与小明生日相差 " + days+"天");
    }
}
